<!-- 全局的toast -->
<template>
  <div class="trip-toast-overlay" ref="showToast">
    <div class="content">
      <div class="trip">{{ message }}</div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
const showToast = ref<HTMLDivElement>()
const props = defineProps({
  message: {
    type: String,
    default: '',
  },
  duration: {
    type: Number,
    default: 2000,
  },
})

onMounted(() => {
  setTimeout(() => {
    showToast.value?.remove()
  }, props.duration)
})
</script>

<style scoped lang="scss">
.trip-toast-overlay {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 999;
  .content {
    position: fixed;
    top: 50%;
    left: 0;
    right: 0;
    width: fit-content;
    max-width: calc(100vw - 72px);
    border-radius: 16px;
    transform: translateY(-50%);
    margin: 0 auto;
    background-color: rgba(27, 27, 27, 0.8);
    padding: 16px 20px;
    .trip {
      color: #fedba3;
      text-align: center;
      font-family: 'PingFang SC';
      font-size: 16px;
      font-style: normal;
      font-weight: 400;
      line-height: normal;
      letter-spacing: -0.667px;
    }
  }
}
</style>
